﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnLineExam.BLL;

namespace OnLineExam.Web.mag.old
{
    public partial class UserPaperList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                string userId = User.Identity.Name;
                string userName = UserManager.GetUserName(userId);
                 

                GridView1.DataSource = UserManager.GetselectUserPaperList2();
                GridView1.DataBind();
            }
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string UserID = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); //取出要删除记录的主键值1
            int PaperID = int.Parse(GridView1.DataKeys[e.RowIndex].Values[1].ToString().Trim());//取出要删除记录的主键值2
            int ScoreID = int.Parse(GridView1.DataKeys[e.RowIndex].Values[2].ToString().Trim());//取出要删除记录的主键值3
            UserManager.DeleteUserPaperList2(UserID, PaperID, ScoreID);
            GridView1.DataSource = UserManager.GetselectUserPaperList2();
            GridView1.DataBind();
            LabelPageInfo.Text = "删除成功！";
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
            {
                Label label1 = e.Row.FindControl("Label1") as Label;
                label1.Text = (e.Row.RowIndex + 1).ToString();

            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#cbe2fa'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
            } 
        }

        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            int pageindex = e.NewPageIndex;
            this.GridView1.PageIndex = pageindex;
        }
    }
}